/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package connection;

import java.net.*;
import java.io.*;
import protocollo.*;


/**
 *
 * @author fabrizioscenna
 */
public class Client {



    private ObjectOutputStream objOut;
    private Socket socket;
   

    public Client(String ip, int port) throws IOException{
        
        socket = new Socket(ip, port);
        objOut = new ObjectOutputStream(socket.getOutputStream());
        System.out.println("***ID " + ip +" client collegato al socket " + socket);
        
        


    }


    public void sendPacchetto(Pacchetto pacchetto) throws Exception{
            System.out.println("message  " + pacchetto);
            objOut.writeObject(pacchetto);
    }


    public void closeSocket(){
        try{
           socket.close();
        } catch(Exception e){
            System.out.println("***ID  client errore in chiusura");

        }

        }


}